//
//  HRPostDynamicViewModel.m
//  Hear
//
//  Created by mac on 2017/4/9.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRPostDynamicViewModel.h"
@implementation HRPostDynamicViewModel
-(void)postDynamicRequstModel:(HRPostDynamicRequestModel*)requstModel isSeccess:(void(^)(HRDynamicModel *dynamicModel))dynamicModel{
    YTKApi *api = [YTKApi apiPostWithUrl:@"MomentsInfo/Post_SaveMoments" parameter:requstModel];
    [api getSuccessToken:^() {
        api.foceNoTocken = NO;
        [api setRequestSerializerType:YTKRequestSerializerTypeHTTP];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            
            NSDictionary *dict = request.responseJSONObject;
            if ([dict[@"CodeStatus"] intValue] == 20000){
                HRDynamicModel *model = [HRDynamicModel modelWithJSON:dict[@"BodyContent"]];
                dynamicModel(model);
            }else{
                dynamicModel(nil);
            }
           
            
            
            
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
            dynamicModel(nil);
        }];
    }];
}
@end
